package net.messagenet.mazor.infra.engine;

import java.util.Date;
import java.util.List;
import java.util.Map;

import net.messagenet.mazor.DO.CustomerDO;
import net.messagenet.mazor.DO.DpaDO;
import net.messagenet.mazor.DO.DpaProductDO;
import net.messagenet.mazor.DO.PosDO;
import net.messagenet.mazor.DO.PosProductDO;
import net.messagenet.mazor.exception.MZRApplicativeException;
import net.messagenet.mazor.exception.MZRInternalServerException;
import net.messagenet.mazor.infra.cache.UserCacheManager;

public interface EngineInterface {
	

	
	/**
	 * 
	 * creates a dpa request
	 * if the dpa contains id then it is loaded changed and marked as not draft
	 * 
	 * 
	 * @param dpa
	 * @throws MZRInternalServerException
	 * @throws MZRApplicativeException
	 */
	public void createDPARequest( DpaDO dpa) throws MZRInternalServerException;
	/**
	 * This method saves the dpa object asa a draft that can loaded later
	 * 
	 * @param dpa dpa data object according to which the excel will be build
	 * @throws MZRInternalServerException
	 */

	public void saveDPADraft( DpaDO dpa) throws MZRInternalServerException;
	
	/**
	 * This method takes a path of an returning DPA request excel file
	 * and update the system with the returning information.
	 * if the DPA sheet doesn't contain DPA ID from dialogic then the DPA is marked as
	 * not approved
	 * 
	 * 
	 * @param path the full path of the uploaded file
	 */
	public void loadDPAAnswerSheet( String path)  throws MZRInternalServerException,MZRApplicativeException;

	
	/**
	 * This method returns a cache manager for usage only
	 * this is good for getting data without hitting the DB
	 * 
	 * @return a userCacheManager
	 */
	public UserCacheManager getCacheManager ();
	
	
	/**
	 * This method is called when the engine is created
	 * 
	 * @throws Exception
	 */
	public void create () throws Exception;
	/**
	 * This method gets all the open dpas that didn't expired and has more product to report
	 * 
	 * @return a map of dpas keyed by the dialogic item #
	 */
	public Map<String,DpaDO> getAllApprovedDPAs();
	/**
	 * 
	 * This method creates a new POS report
	 * 
	 * @param posDo
	 * @param dpaProd - if the a product inside the pos was taken form a dpa this list should have an object
	 * 					in corresponding index
	 * @throws MZRApplicativeException 
	 * @throws MZRInternalServerException 
	 */
	public void createNewPOSRequest(PosDO  posDo) throws MZRInternalServerException;

	/**
	 * This method creates new customer in the system
	 * 
	 * @param customer
	 */
	public void createOrEditCustomer(CustomerDO customer)throws MZRInternalServerException;

	/**
	 * This method returns all the products in the dpa that were reported in the pos and didn't
	 * payment
	 * 
	 * @param fromDate
	 * @param toDate
	 * @return a list of all the products
	 */
	public List<DpaProductDO> getDPAReportedProducts(Date fromDate, Date toDate);

	/**
	 * This method updates the paid quantity in the dpa products after refunding
	 * 
	 * 
	 * @param products
	 */
	public void updatePaidProducts(List<DpaProductDO> products);
	/**
	 * returns all the dpa drafts
	 * 
	 * @return a list of all dpa defined as drafts
	 */
	public List<DpaDO> getDPADrafts();
	/**
	 * given a list of dpa product this method removes those products form the DB
	 * 
	 * 
	 * @param removePrds
	 */
	public void removeDPAProducts(List<DpaProductDO> removePrds);
	/**
	 * returns all the pos drafts
	 * 
	 * @return a list of all pos defined as drafts
	 */
	public List<PosDO> getPOSDrafts();
	/**
	 * This method saves the dpa object as a draft that can loaded later
	 * 
	 * @param pos - pos data object
	 * @throws MZRInternalServerException
	 */

	public void savePOSDraft(PosDO pos);
	/**
	 * given a list of pos product this method removes those products form the DB
	 * 
	 * 
	 * @param removePrds
	 */
	public void removePOSProducts( List<PosProductDO> removePrds);
	
	/**
	 * gets all the dpas that are not closed (has didn't receive full payment for all the products )
	 * 
	 * @return a map of dpas keyed by the dialogic item #
	 */
	public Map<Integer, DpaDO> getAllNotClosedDPAs();

	/**
	 * This method returns all the closed dpa and not approved dpas
	 * 
	 * @return
	 */
	public List<DpaDO> getClosedAndNotApprovedDPAs();
	/**
	 * This method returns all the DPAs in the system form draft to new DPA mapped by id
	 * 
	 * @return 
	 */
	public Map<Integer, DpaDO> getAllDPAs();


}
